package com.probox.common.entity.domain.product;

import java.util.ArrayList;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.probox.common.core.enums.CategoryDepth;
import com.probox.common.core.enums.CategoryShow;
import com.probox.common.core.enums.DataStatus;
import com.probox.common.entity.domain.product.vo.PddCategory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.*;
import com.probox.common.core.annotation.Excel;

/**
 * 商品类别对象 product_category
 *
 * @date 2021-05-26
 */
@Data
@Accessors(chain = true)
@TableName("product_category")
@ApiModel(description = "商品类别")
public class ProductCategory implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 商品分类ID
     */
    //默认主键自增
    @TableId(value = "CATEGORY_UID", type = IdType.AUTO)
    @ApiModelProperty(value = "类别UID")
    private Long categoryUid;
    /**
     * 上级ID
     */
    @ApiModelProperty(value = "上级ID")
    private Long categoryPuid;
    /**
     * 平台ID
     */
    @ApiModelProperty(value = "平台ID")
    private Long platformUid;
    /**
     * 分类名称
     */
    @Excel(name = "分类名称")
    @ApiModelProperty(value = "分类名称")
    private String categoryName;
    /**
     * 分类图片URL
     */
    @Excel(name = "分类图片URL")
    @ApiModelProperty(value = "分类图片URL")
    private String categoryImgUrl;
    /**
     * 数据状态
     */
    @Excel(name = "数据状态")
    @ApiModelProperty(value = "数据状态")
    private String dataStatus;
    /**
     * 排序
     */
    @Excel(name = "排序")
    @ApiModelProperty(value = "排序")
    private Long dataPriority;
    /**
     * 上级的ID集
     */
    @ApiModelProperty(hidden = true)
    private String categoryUidList;
    /**
     * 层级(0,1,2)
     */
    @Excel(name = "层级(0,1,2)")
    @ApiModelProperty(value = "层级")
    private Integer categoryDepth;
    /**
     * 更新人ID
     */
    @Excel(name = "更新人ID")
    @ApiModelProperty(hidden = true)
    private Long updateUid;
    /**
     * 更新人名称
     */
    @Excel(name = "更新人名称")
    @ApiModelProperty(hidden = true)
    private String updateName;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(hidden = true)
    private Date updateTime;

    /**
     * 分类banner图(1张)
     */
    @Excel(name = "分类banner图(1张)")
    @ApiModelProperty(value = "分类banner图")
    private String categoryBanner;
    /**
     * 是否展示(1/展示，0/不展示)
     */
    @Excel(name = "是否展示(1/展示，0/不展示)")
    @ApiModelProperty(value = "是否显示")
    private String isShow;
    /**
     * 发货时间
     */
    @Excel(name = "发货时间")
    @ApiModelProperty(value = "发货时间")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String arrivalTime;

    @TableField(exist = false)
    @ApiModelProperty(value = "商品分类级联")
    private List<ProductCategory> children = new ArrayList<ProductCategory>();

    // pdd 测试分类uid
    private Long pddCategoryUid;

    @Excel(name = "分组ID")
    @ApiModelProperty(value = "分组ID")
    private Long groupUid;

    @TableField(exist = false)
    @Excel(name = "分组名称")
    private String groupName;


    public ProductCategory() {

    }


    public ProductCategory(PddCategory category, Long userId, String userName, Long platformUid) {
        this.updateUid = userId;
        this.updateName = userName;
        this.updateTime = DateUtil.date();
        this.isShow = CategoryShow.hide.getKey();
        this.categoryDepth = CategoryDepth.one.getKey();
        this.dataPriority = 10L;
        this.categoryPuid = 0L;
        this.categoryName = category.getCatName();
        this.pddCategoryUid = category.getCatId();
        this.platformUid = platformUid;
        this.dataStatus = DataStatus.valid.getKey();
    }
}
